import {BIApi} from './index';
import server from './request';

// 微信支付
function wechatFetch(payload) {
  const uri = BIApi + 'api/WxPay/WxPayApp?' + server.getParams(payload);
  return server.requestPromise({uri: uri, method: 'GET'});
}
// 绑定合伙人提现微信账号
function BindDealerWithdrawalOpenid(payload) {
  const uri = BIApi + 'api/Dealer/BindDealerWithdrawalOpenid';
  return server.requestPromise({uri: uri, method: 'POST', body: payload});
}
// 合伙人提现至微信零钱
function WithdrawalToWeChat(payload) {
  const uri = BIApi + 'api/Dealer/WithdrawalToWeChat';
  return server.requestPromise({uri: uri, method: 'POST', body: payload});
}

// 获取用户微信信息
function GetOpenidByCode(payload) {
  const uri =
    BIApi + 'api/Dealer/GetOpenidByCode' + server.getParams(payload);
  return server.requestPromise({uri: uri, method: 'GET'});
}
// 下单
function gotoOrderSave(payload) {
  const uri = BIApi + 'api/Order/OrderSave';
  return server.requestPromise({uri: uri, method: 'POST', body: payload});
}
/* cg */
/* 
视图层Demo:
fetchApi.BUserRegist(this.state.model).then(res => {
    console.log(res);   
    if(res.ok!=null && !res.ok){
        that.setState({errText:res.status});
        return;
    }
    that.setState({errText:res.message})
    if(res.code==200){
     that.props.navigation.goBack();
    }
}).catch(error => {
    Layer.showMsgNoback(error.message);
});  */

function BUserRegist(payload) {
  const uri = BIApi + 'api/Dealer/BUserRegist';
  return server.requestPromise({uri: uri, method: 'POST', body: payload});
}

function GetContract(payload) {
  const uri = BIApi + 'api/Contract/GetContract';
  return server.requestPromise({uri: uri, method: 'POST', body: payload});
}
/* cg end */

// 查询组员信息
function GetUserGroup(payload) {
  const uri =
    BIApi + 'api/Dealer/GetUserGroup?' + server.getParams(payload);
  return server.requestPromise({uri: uri, method: 'GET'});
}
// 新增组员
function AddChildGroup(payload) {
  const uri = BIApi + 'api/Dealer/AddChild?' + server.getParams(payload);
  return server.requestPromiseJson({uri: uri, method: 'POST'});
}
// 根据手机号查询manageruser信息
function GetManagerUserByPhone(payload) {
  const uri =
    BIApi +
    'api/Dealer/GetManagerUserByPhone?' +
    server.getParams(payload);
  return server.requestPromise({uri: uri, method: 'GET'});
}

// 获取收支账单
function GetBalanceChangeRecordsInfo(payload) {
  const uri = BIApi + 'api/Dealer/GetBalanceChangeRecordsInfo';
  return server.requestPromise({uri: uri, method: 'POST', body: payload});
}

// 用户登录
function LoginApp(payload) {
  const uri = BIApi + 'api/Dealer/Login';
  return server.requestPromise({uri: uri, method: 'POST', body: payload});
}

// 查询支付密码设置状态
function GetMGwithdrawalPsdStatus(payload) {
  const uri =
    BIApi +
    'api/Dealer/GetMGwithdrawalPsdStatus?' +
    server.getParams(payload);
  return server.requestPromise({uri: uri, method: 'GET'});
}

/* cg end  */
module.exports = {
  wechatFetch: wechatFetch,
  BindDealerWithdrawalOpenid: BindDealerWithdrawalOpenid,
  GetOpenidByCode: GetOpenidByCode,
  WithdrawalToWeChat: WithdrawalToWeChat,
  gotoOrderSave: gotoOrderSave,
  /* cg */
  BUserRegist: BUserRegist,
  GetContract: GetContract,
  GetUserGroup: GetUserGroup,
  AddChildGroup: AddChildGroup,
  GetManagerUserByPhone: GetManagerUserByPhone,
  GetBalanceChangeRecordsInfo: GetBalanceChangeRecordsInfo,
  LoginApp: LoginApp,
  GetMGwithdrawalPsdStatus: GetMGwithdrawalPsdStatus,
};
